package leecode.数组和字符串.数组拆分;

import java.util.Arrays;

public class arrayPairSum {
    public static void main(String[] args) {
        int[] nums = {6, 2, 6, 5, 1, 2};
        Soulution soulution = new Soulution();
        int i = soulution.arrayPairSum(nums);
        System.out.println(i);
    }

    static class Soulution {
        public int arrayPairSum(int[] nums) {
            Arrays.sort(nums);
            int sum = 0;
            for (int i = 0; i < nums.length; i += 2) {
                sum += nums[i];
            }
            return sum;
        }
    }
}
